<script>
	import { promisify, http, storage } from './utils/utils';
	import api from './utils/api';
	import { navigateTo, switchTab } from './utils/wxApi';
	import { getPage } from './utils/config';
	import { login } from './utils/login';
	export default {
		// //全局数据
		globalData: {
			g_cid: 0,
			pid: 0,
			zoneid: 0,
			mylocation: {},
			zone: null,
			isImLogin:false,
			unReadMsg:0,
			v_count:0,
			/**
			 * 
			 * 
			 * 设置经纬度
			 */
			setlocation(t) {
				storage.set('mylocation', t);
			},

			/**
			 * 更新购物车
			 */
			setbdCart(t) {
				storage.set('bdcartCount', t);
			},

			/**
			 * 更新购物车
			 */
			setCart(t) {
				if (t) {
					uni.setTabBarBadge({
						index: 3,
						text: `${t}`
					});
				} else {
					uni.removeTabBarBadge({
						index: 3
					});
				}
				storage.set('cartCount', t);
			},

			/**
			 * 登录态获取
			 */
			getLogin() {
				return new Promise((resolve, reject) => {
					login
						.logged()
						.then((res) => {
							resolve(res);
						})
						.catch((res) => {
							reject(res);
						});
				});
			},

			/**
			 * 存储登录
			 */
			setLogon(data, mode, cb) {
				login.logon(data, mode, cb);
			}
		},
		onLaunch: function() {
			console.log('App Launch')
			uni.hideTabBar()
			uni.removeStorageSync('selectedIndex');
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	@import '@/static/wxss/index.css';
</style>
